from turtle import forward
from nets.bases.basicmodel import BasicModule
import torch as t
import torch.nn as nn
import torch.nn.functional as F

# 深度可分离卷积
class DepthWiseConv(nn.Module):
    def __init__(self,in_ch,out_ch, kernel_size = 3, stride = 1, padding = 1, bias= False):
        super(DepthWiseConv, self).__init__()
        # 也相当于分组为1的分组卷积
        self.point_conv = nn.Conv2d(in_channels=in_ch,
                                    out_channels=in_ch,
                                    kernel_size=1,
                                    stride=1,
                                    padding=0,
                                    bias=bias)
        
        self.depth_conv = nn.Conv2d(in_channels=in_ch,
                                    out_channels=out_ch,
                                    kernel_size=kernel_size,
                                    stride=stride,
                                    padding=padding,
                                    bias=bias,
                                    groups=in_ch)
        
        
    def forward(self,x):
        # print(x.shape)
        x = self.point_conv(x)
        x = self.depth_conv(x)
        return x